package com.example.egweibo1.base.response;

import lombok.Data;

/**
 * @author tune_the last
 * @date 2025/11/13 - 17:30
 */
@Data
public class Result<T> {
    private Integer stateCode;
    private String message;
    private T data;

    private static <T> Result<T> build(T data, StatusCode statusCode){
        Result<T> result = new Result<>();
        result.setData(data);
        result.setStateCode(statusCode.getStateCode());
        result.setMessage(statusCode.getMessage());
        return result;
    }

    public static <T> Result<T> ok(){
        return build(null, StatusCode.OPERATION_SUCCESS);
    }

    public static <T> Result<T> ok(T data){
        return build(data, StatusCode.OPERATION_SUCCESS);
    }
    public static <T> Result<T> fail(){
        return build(null, StatusCode.OPERATION_SUCCESS);
    }
}
